class Solution {
public:
    int distanceTraveled(int mainTank, int additionalTank)
    {
        int ans = 0;
        int count = 0;
        while (mainTank > 0)
        {
            mainTank--;
            count++;
            ans += 10;
            if (count == 5 && additionalTank > 0)
            {
                mainTank++;
                count = 0;
                additionalTank--;
            }
        }
        return ans;
    }
};